package com.hqq.concurrency.reactor.example;

import java.io.IOException;
import java.nio.channels.SocketChannel;

/**
 * Accepter
 * Created by heqianqian on 2017/8/5.
 */
public class Accepter implements Runnable {

    private Reactor reactor;

    public Accepter(Reactor reactor) {
        this.reactor = reactor;
    }

    @Override
    public void run() {
        try {
            SocketChannel socketChannel = reactor.serverSocketChannel.accept();
            if (socketChannel!=null){//调用handler来处理channel
                new SocketReadHandler(reactor.selector,socketChannel);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}